package com.example.prison.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.prison.entity.HistoricalAlarmData;
import com.example.prison.service.HistoricalAlarmDataService;
import com.example.prison.mapper.HistoricalAlarmDataMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author jiang
* @description 针对表【historical_alarm_data】的数据库操作Service实现
* @createDate 2024-01-17 15:49:31
*/
@Service
public class HistoricalAlarmDataServiceImpl extends ServiceImpl<HistoricalAlarmDataMapper, HistoricalAlarmData>
    implements HistoricalAlarmDataService{

    @Autowired
    private HistoricalAlarmDataMapper historicalAlarmDataMapper;

    @Override
    public PageInfo<HistoricalAlarmData> get(int pageNumber, int pageSize, String defenseSection, String startTime, String endTime) {
        PageHelper.startPage(pageNumber, pageSize);
        return new PageInfo<>(historicalAlarmDataMapper.get(defenseSection,startTime,endTime));
    }

    @Override
    public int add(HistoricalAlarmData record) {
        historicalAlarmDataMapper.add(record);
        return 1;
    }

    @Override
    public int delete(Integer[] ids) {
        historicalAlarmDataMapper.delete(ids);
        return 1;
    }

    @Override
    public int update(HistoricalAlarmData data, Integer id) {
        if(data.getId() > 1) {
            historicalAlarmDataMapper.update(data, id);
            return -1;
        } else {
            return 1;
        }
    }

    @Override
    public HistoricalAlarmData getOneAlarmData(String defenseSection, String alarmLevel, String alarmStatus) {
        return historicalAlarmDataMapper.getOneAlarmData( defenseSection,  alarmLevel,  alarmStatus);
    }

}




